package com.vecspace.dayu.code.pojo;

import java.util.Map;
import javax.persistence.Table;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;

import com.vecspace.data.model.IdEntity;
import com.vecspace.data.model.RowMapper;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/** DAYU-用户配置信息
 * @author wanghua
 */
@Entity
@Polymorphism(type = PolymorphismType.EXPLICIT)
@Table(name = "DAYU_CODE_USER_PROPERTY")
public class UserProperty implements IdEntity, java.io.Serializable {
	
	private static final long serialVersionUID = 4921810978033407638L;
	public UserProperty(){
	}

	private Long id;
	/**逻辑ID*/
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "ID")
	public Long getId(){
		return id;
	}
	/**逻辑ID*/
	public void setId(Long value){
		this.id = value;
	}

	private String loginId;
	/**LoginID*/
	@Column(name = "LOGIN_ID")
	public String getLoginId(){
		return loginId;
	}
	/**LoginID*/
	public void setLoginId(String value){
		this.loginId = value;
	}

	private String propName;
	/**配置项名称*/
	@Column(name = "PROP_NAME")
	public String getPropName(){
		return propName;
	}
	/**配置项名称*/
	public void setPropName(String value){
		this.propName = value;
	}

	private String valueStr;
	/**配置项值(字符串)*/
	@Column(name = "VALUE_STR")
	public String getValueStr(){
		return valueStr;
	}
	/**配置项值(字符串)*/
	public void setValueStr(String value){
		this.valueStr = value;
	}

	private Long valueNum;
	/**配置项值(整数)*/
	@Column(name = "VALUE_NUM")
	public Long getValueNum(){
		return valueNum;
	}
	/**配置项值(整数)*/
	public void setValueNum(Long value){
		this.valueNum = value;
	}

	
	public void parseFrom(Map<String, Object> row){
		RowMapper rowMapper = new RowMapper(row);
		this.id = rowMapper.getLong("ID");
		this.loginId = rowMapper.getString("LOGIN_ID");
		this.propName = rowMapper.getString("PROP_NAME");
		this.valueStr = rowMapper.getString("VALUE_STR");
		this.valueNum = rowMapper.getLong("VALUE_NUM");
	}

	@Override
	public boolean equals(Object obj) {
		if(obj == null)return false;
		if(id == null)return false;
		UserProperty other = (UserProperty)obj;
		return id.equals(other.id);
	}

	@Override
	public int hashCode() {
		if(id == null)return 0;
		return id.hashCode();
	}
}
